/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import view.Screen;
import jplay.*;

/**
 *
 * @author Marcel
 */
public class StartScreen extends Screen {
    
    private GameScreen gameScreen;
    private GameImage background;
    private Sprite startButton;
    private Sprite optionsButton;
    private Sprite exitButton;
    private boolean running;

    public StartScreen() {
        //Start 
        background = new GameImage("Images/spaceBackground.jpg");
        exitSprite = new Sprite("Images/exit.png");
        exitSprite.x = getResolution().getX() / 2 - exitSprite.width / 2;
        exitSprite.y = (3. / 4.) * getResolution().getY() - exitSprite.height / 2;
        newGameSprite = new Sprite("Images/Start1.png");
        newGameSprite.x = getResolution().getX() / 2 - newGameSprite.width / 2;
        newGameSprite.y = (1. / 2.) * getResolution().getY() - newGameSprite.height / 2;
        running = true;

        //Update
        while (running) {

            background.draw();
            exitSprite.draw();
            newGameSprite.draw();

            capturaEvento();

            newGameSprite.update();
            exitSprite.update();
            getWindow().update();
        }
        //Finaliza
        getWindow().exit();
    }

    private void capturaEvento() {
        if (getMouse().isLeftButtonPressed()) {
            if (getMouse().isOverObject(exitSprite)) {
                running = false;
            } else if (getMouse().isOverObject(newGameSprite)) {
                running = false;
                gameScreen = new GameScreen();
            }
        }
    }
}
